<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.example.bean.Notice, com.example.dao.NoticeDAO, java.util.List" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>公告列表</title>
  <!-- 引入Bootstrap 5 -->
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <!-- 引入Bootstrap Icons -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
  <style>
    :root {
      --primary-color: #4361ee;
      --secondary-color: #3f37c9;
      --accent-color: #4895ef;
      --light-bg: #f8f9fa;
    }

    body {
      background-color: var(--light-bg);
      padding: 20px;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .header-section {
      background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
      color: white;
      padding: 30px 0;
      border-radius: 10px;
      margin-bottom: 30px;
      box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .notice-card {
      background: white;
      border-radius: 10px;
      box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08);
      margin-bottom: 25px;
      transition: transform 0.3s ease, box-shadow 0.3s ease;
      overflow: hidden;
      border: none;
    }

    .notice-card:hover {
      transform: translateY(-5px);
      box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }

    .card-header {
      background-color: #f9fafb;
      padding: 15px 20px;
      border-bottom: 1px solid #edf2f7;
      font-weight: 600;
      color: var(--secondary-color);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .card-body {
      padding: 25px;
    }

    .publisher-info {
      display: flex;
      align-items: center;
      gap: 10px;
      color: #6c757d;
      font-size: 0.9rem;
      margin-bottom: 15px;
    }

    .time-badge {
      background-color: #e9ecef;
      color: #495057;
      padding: 5px 10px;
      border-radius: 20px;
      font-size: 0.85rem;
    }

    .empty-state {
      text-align: center;
      padding: 50px 20px;
      background: white;
      border-radius: 10px;
      box-shadow: 0 3px 10px rgba(0, 0, 0, 0.05);
    }

    .empty-icon {
      font-size: 4rem;
      color: #dee2e6;
      margin-bottom: 20px;
    }
  </style>
</head>
<body>
<div class="container">
  <div class="header-section text-center">
    <h1><i class="bi bi-megaphone me-2"></i>公告列表</h1>
    <p class="lead">最新通知与重要信息一览</p>
  </div>

  <%
    NoticeDAO dao = new NoticeDAO();
    List<Notice> noticeList = dao.getAllNotices();
    if (noticeList != null && !noticeList.isEmpty()) {
      for (Notice notice : noticeList) {
  %>
  <div class="notice-card">
    <div class="card-header">
      <h2 class="h4 mb-0"><i class="bi bi-pin-angle me-2"></i><%= notice.getTitle() %></h2>
      <span class="time-badge"><i class="bi bi-clock me-1"></i><%= notice.getPublishTime() %></span>
    </div>
    <div class="card-body">
      <div class="publisher-info">
        <i class="bi bi-person-circle"></i>
        <span>发布者: <%= notice.getPublisher() %></span>
      </div>
      <div class="notice-content">
        <p class="mb-0"><%= notice.getContent() %></p>
      </div>
    </div>
  </div>
  <%
    }
  } else {
  %>
  <div class="empty-state">
    <div class="empty-icon">
      <i class="bi bi-inbox"></i>
    </div>
    <h3 class="h4">暂无公告信息</h3>
    <p class="text-muted">当前没有可显示的公告，请稍后再来查看</p>
  </div>
  <%
    }
  %>
</div>

<!-- 引入Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>